import { EnumSchema } from '@/utils/common/types';
import { PresetColorEnum } from '@/enums/colorEnum';

//#region 库区类型
export enum WareHouseAreaTypeEnum {
  Material = 0,
  HalfProduct,
  Product,
}

export class WareHouseAreaTypeEntity {
  Type: WareHouseAreaTypeEnum;
  /** 显示描述 */
  Display: string;
  /** 颜色 */
  Color?: PresetColorEnum | string;

  constructor(wareHouseAreaType: WareHouseAreaTypeEnum, color?: PresetColorEnum | string) {
    this.Type = wareHouseAreaType;
    this.Color = color;
    switch (wareHouseAreaType) {
      case WareHouseAreaTypeEnum.Material:
        this.Display = '原料';
        this.Color = this.Color ? this.Color : PresetColorEnum.Green;
        break;
      case WareHouseAreaTypeEnum.HalfProduct:
        this.Display = '半成品';
        this.Color = this.Color ? this.Color : PresetColorEnum.Blue;
        break;
      case WareHouseAreaTypeEnum.Product:
        this.Display = '成品';
        this.Color = this.Color ? this.Color : PresetColorEnum.Cyan;
        break;
    }
  }
}

export function getWareHouseAreaTypeEnumSchema(enableTag = true): EnumSchema[] {
  const enumSchema: EnumSchema[] = [];
  const typeEntities: WareHouseAreaTypeEntity[] = [
    new WareHouseAreaTypeEntity(WareHouseAreaTypeEnum.Material),
    new WareHouseAreaTypeEntity(WareHouseAreaTypeEnum.HalfProduct),
    new WareHouseAreaTypeEntity(WareHouseAreaTypeEnum.Product),
  ];
  typeEntities.forEach((item) => {
    enumSchema.push({
      key: item.Type as number,
      label: item.Display,
      value: item.Type as number,
      tag: enableTag,
      tagColor: item.Color,
    });
  });
  return enumSchema;
}
//#endregion
